<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">

<head>
  <meta charset="UTF-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <link rel="shortcut icon" href="img/logo/rjh.ico" />
  <link rel="stylesheet" href="css/element-ui.css" />
  <title th:text="${accessParam.get('title')}">报表导出</title>
  <script src="js/common/vue.js"></script>
  <script src="js/common/element-ui.js"></script>
  <script src="js/common/jquery.min.js"></script>
  <script>
    var getRootPath = function () {
      //获取当前网址，如： http://localhost:8083/uimcardprj/share/meun.jsp
      var curWwwPath = window.document.location.href;
      //获取主机地址之后的目录，如： uimcardprj/share/meun.jsp
      var pathName = window.document.location.pathname;
      var pos = curWwwPath.indexOf(pathName);
      //获取主机地址，如： http://localhost:8083
      var localhostPaht = curWwwPath.substring(0, pos);
      //获取带"/"的项目名，如：/uimcardprj
      var projectName = pathName.substring(0, pathName.substr(1).indexOf('/') + 1);
      return (localhostPaht + projectName + '/');
    };

    // 日期原型上增加 format 方法 date.format('yyyy-MM-dd') 返回 String
    Date.prototype.format = function (format) {
      var date = {
        "M+": this.getMonth() + 1,
        "d+": this.getDate(),
        "h+": this.getHours(),
        "m+": this.getMinutes(),
        "s+": this.getSeconds(),
        "q+": Math.floor((this.getMonth() + 3) / 3),
        "S+": this.getMilliseconds()
      };
      if (/(y+)/i.test(format)) {
        format = format.replace(RegExp.$1, (this.getFullYear() + '').substr(4 - RegExp.$1.length));
      }
      for (var k in date) {
        if (new RegExp("(" + k + ")").test(format)) {
          format = format.replace(RegExp.$1, RegExp.$1.length == 1 ?
            date[k] : ("00" + date[k]).substr(("" + date[k]).length));
        }
      }
      return format;
    };
  </script>
</head>

<body>
  <div th:switch="${accessParam.get('path')}">
    <!-- 供应商不良记录查询 -->
    <div th:case="'index'">
      <ul id="index">
        <li><a v-bind:href="a1">账户余额查询</a></li>
        <li><a v-bind:href="a2">供应商不良记录导出</a></li>
        <li><a v-bind:href="a3">医保代码导出</a></li>
        <li><a v-bind:href="a4">领用收货单查询</a></li>
      </ul>
      <script>
        /*<![CDATA[*/
         window.onload = function onload() {
           var baseUrl = getRootPath();
           new Vue({
             el: '#index',
             data : {
               a1: baseUrl + 'html/balanceQuery.html',
               a2: baseUrl + 'badRecord',
               a3: baseUrl + 'medicareCode',
               a4: baseUrl + 'html/billQuery.html?id=17052400000271'
             }
           })
         }
        /*]]>*/
      </script>
    </div>
    <!-- 供应商不良记录查询 -->
    <div th:case="'badRecord'">
      <div id="badRecordRoot"></div>
      <script>
        /*<![CDATA[*/
        window.onload = function onload() {
          var htmlTemp = $.ajax({ url: getRootPath() + "/reportTemp/badRecord.html", async: false }).responseText;
          var root$ = document.querySelector('#badRecordRoot');
          root$.innerHTML = htmlTemp;
          var vm = new Vue({
            el: '#badRecordRoot',
            data: {
              queryParam: {
                startTime: '',
                endTime: ''
              }
            },
            methods: {
              exportExcel: function () {
                if (this.queryParam.startTime && this.queryParam.endTime) {
                  var url = getRootPath() +
                    "deptExcelExport/badRecord?startTime=" +
                    this.queryParam.startTime.format('yyyy-MM-dd') +
                    "&endTime=" +
                    this.queryParam.endTime.format('yyyy-MM-dd');
                  window.location.href = url;
                } else {
                  this.$message('请选择时间范围');
                }
              }
            }
          })
        }
        /*]]>*/
      </script>
    </div>
    <!-- 医保代码导出 -->
    <div th:case="'medicareCode'">
      <div id="medicareCode"></div>
      <script>
        /*<![CDATA[*/
        window.onload = function onload() {
          var htmlTemp = $.ajax({ url: getRootPath() + "/reportTemp/medicareCode.html", async: false }).responseText;
          var root$ = document.querySelector('#medicareCode');
          root$.innerHTML = htmlTemp;
          var vm = new Vue({
            el: '#medicareCode',
            data: {
              queryParam: {
                startTime: '',
                endTime: '',
                count: 100
              }
            },
            methods: {
              exportExcel: function () {
                if (!this.queryParam.startTime && !this.queryParam.endTime) {
                  this.$message('请选择时间范围');
                  return;
                }

                if(!this.queryParam.count) {
                  this.$message('请选择导出记录数量');
                  return;
                }

                var url = getRootPath() +
                  "deptExcelExport/medicareCode?startTime=" +
                  this.queryParam.startTime.format('yyyy-MM-dd') +
                  "&endTime=" +
                  this.queryParam.endTime.format('yyyy-MM-dd') +
                  "&count=" + this.queryParam.count;
                window.location.href = url;
              }
            }
          })
        }
        /*]]>*/
      </script>
    </div>
    
    
    
    <!-- test -->
    <div th:case="'medicareCode'">
      <div id="medicareCode"></div>
      <script>
        /*<![CDATA[*/
        window.onload = function onload() {
          var billListYgsqTemp = $.ajax({ url: getRootPath() + "/js/pages/html/index/bill/billListYgsqTemp.html", async: false }).responseText;
          var root$ = document.querySelector('#billListYgsqTemp');
          root$.innerHTML = billListYgsqTemp;
          var vm = new Vue({
            el: '#billListYgsqTemp',
            data: {
              queryParam: {
                startTime: '',
                endTime: '',
                count: 100
              }
            },
            methods: {
              exportExcel: function () {
                if (!this.queryParam.startTime && !this.queryParam.endTime) {
                  this.$message('请选择时间范围');
                  return;
                }

                if(!this.queryParam.count) {
                  this.$message('请选择导出记录数量');
                  return;
                }

                var url = getRootPath() +
                  "deptExcelExport/medicareCode?startTime=" +
                  this.queryParam.startTime.format('yyyy-MM-dd') +
                  "&endTime=" +
                  this.queryParam.endTime.format('yyyy-MM-dd') +
                  "&count=" + this.queryParam.count;
                window.location.href = url;
              }
            }
          })
        }
        /*]]>*/
      </script>
    </div>
  </div>

</body>

</html>